#yearEdits.py

import os
import sys
import collections

def main():

	path = sys.argv[1]
	files = os.listdir(path)
	yearDict = collections.defaultdict(list)
	

	for nsfile in sorted(files):
		f = open(path+nsfile,"r")
		for line in f:
			pieces = line.split(' ')
			if pieces[0] == "Stats":
				year = pieces[-1].strip()[-8:-4]
			if pieces[0] <> "TOTAL" and pieces[0] <> "Stats":
				yearDict[str(int(year)+int(pieces[0]))].append(pieces[1].replace('\n',''))
	
	name = path.split('/')[-2]
	
	for key in sorted(yearDict.keys()):
		if key <> "2012":
			for x in range(int(key),2011):
				yearDict[key].append(str(0))
			print name.replace(' ','') + key + " <- c(" + ",".join(yearDict[key]) + ')'

main()
